


import book.Booklist;
import user.AdminUser;
import user.NormalUser;
import user.User;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: wx
 * Date: 2023-11-14
 * Time: 15:21
 */
public class Main {

    public static User login() {
        System.out.println("请输入你的姓名: ");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();

        System.out.println("请输入你的身份: 1.管理员   2.普通用户");
        int choice = scanner.nextInt();

        if(choice == 1){
            //管理员
             return new AdminUser(name);
        }else {
            //普通用户
             return new NormalUser(name);
        }

    }

    public static void main(String[] args) {

        //user指向那个对象,就看返回值
        Booklist booklist = new Booklist();
        User user = login();
        int choice =user.menu();

        //System.out.println("你的操作是 " + choice);

        //根据 choice 来决定调用的是哪个方法  ?
        //调用user指向对象的操作方法

        user.doOperation(choice,booklist);

    }
}
